<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 目标对象
    let data = {
        msg: "hello world",
        count: 100,
        info: {
            name:"张三",
            age:18,
        }
    }

    // 代理对象
    var proxyData = new Proxy(data,{
        get(target,key){
            console.log("取值拦截",target,key);

            return target[key];
        },
        set(target,key,val){
            console.log("赋值拦截",target,key,val);
            target[key] = val;
        },
    });

    proxyData.info = new Proxy(proxyData.info,{
        get(target,key){
            console.log("取值拦截",target,key);

            return target[key];
        },
        set(target,key,val){
            console.log("赋值拦截",target,key,val);
            target[key] = val;
        },
    });


    // console.log(proxyData);
    
    // console.log(proxyData.msg);
    // proxyData.msg = "hello Vue";
    // console.log(data);
    // proxyData.info.name = "李四";

    proxyData.bool = true;




</script>
</html>